<?php
$this->headScript()->appendFile(_STATIC_HTTP . '/jquery/datepicker.js');
$this->headLink()->prependStylesheet(_STATIC_HTTP . '/admin/css/datepicker.css');
$name = isset($this->name) ? $this->name : 'datetime';
$id = preg_replace('/[\[\]\.]+/sU', '-', $name);
if(!isset($this->time) || !$this->time) {
	$time = system_date::timestamp();
} elseif ($this->time instanceof system_date) {
	$time = $this->time->get();
} else {
	$time = $this->time;
}
echo '<div id="_' . $name . '">';
echo '<input type="text" value="' . date('Y-m-d', $time) . '" size="12" name="' . $name . '[date]" id="' . $id . '-date" />';
echo '<select name="' . $name . '[hour]">';
for($i = 0; $i < 24; $i++) {
	echo '<option value="' . $i . '"';
	if(intval(date('H', $time)) == $i) echo ' selected="selected"';
	echo '>' . (strlen($i) == 1 ? '0' . $i : $i) . '</option>';
}
echo '</select><strong> : </strong><select name="' . $name . '[minute]">';
for($i = 0; $i < 60; $i++) {
	echo '<option value="' . $i . '"';
	if(intval(date('i', $time)) == $i) echo ' selected="selected"';
	echo '>' . (strlen($i) == 1 ? '0' . $i : $i) . '</option>';
}
echo '</select><strong> : </strong><select name="' . $name . '[second]">';
for($i = 0; $i < 60; $i++) {
	echo '<option value="' . $i . '"';
	if(intval(date('s', $time)) == $i) echo ' selected="selected"';
	echo '>' . (strlen($i) == 1 ? '0' . $i : $i) . '</option>';
}
echo '</select>';
echo '</div>';
?>
<?php $this->headScript()->captureStart();?>
$(document).ready(function(){
	$("#<?php echo $id . '-date';?>").datepicker({changeMonth:true,changeYear:true,dateFormat:'yy-mm-dd'});
});
<?php $this->headScript()->captureEnd();?>